import time

def s(n):
    swap = True
    while swap:
        swap = False
        for i in range(len(n) - 1):
            if n[i] > n[i + 1]:
                n[i], n[i + 1] = n[i + 1], n[i]
                swap = True

def r2l(namefile):
    file = open(namefile, "r")
    data = file.readlines()
    return data

m1 = r2l("m1_sorted.txt")
m2 = r2l("m2_reverse.txt")
m3 = r2l("m3_shuffle.txt")

timestart = time.time()
s(m1)
timefinish = time.time()
print("m1_sorted", round(timefinish - timestart) * 1000, "milliseconds")

timestart = time.time()
s(m2)
timefinish = time.time()
print("m2_reverse", round(timefinish - timestart) * 1000, "milliseconds")

timestart = time.time()
s(m3)
timefinish = time.time()
print("m3_shuffle", round(timefinish - timestart) * 1000, "milliseconds")
